package com.ruoyi.project.digital.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.digital.domain.PetMessage;
import com.ruoyi.project.digital.service.IPetMessageService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户宠物聊天信息Controller
 * 
 * @author ruoyi
 * @date 2023-11-01
 */
@RestController
@RequestMapping("/digital/message")
public class PetMessageController extends BaseController
{
    @Autowired
    private IPetMessageService petMessageService;

    /**
     * 查询用户宠物聊天信息列表
     */
    @PreAuthorize("@ss.hasPermi('digital:message:list')")
    @GetMapping("/list")
    public TableDataInfo list(PetMessage petMessage)
    {
        startPage();
        List<PetMessage> list = petMessageService.selectPetMessageList(petMessage);
        return getDataTable(list);
    }

    /**
     * 导出用户宠物聊天信息列表
     */
    @PreAuthorize("@ss.hasPermi('digital:message:export')")
    @Log(title = "用户宠物聊天信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PetMessage petMessage)
    {
        List<PetMessage> list = petMessageService.selectPetMessageList(petMessage);
        ExcelUtil<PetMessage> util = new ExcelUtil<PetMessage>(PetMessage.class);
        return util.exportExcel(list, "message");
    }

    /**
     * 获取用户宠物聊天信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('digital:message:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(petMessageService.selectPetMessageById(id));
    }

    /**
     * 新增用户宠物聊天信息
     */
    @PreAuthorize("@ss.hasPermi('digital:message:add')")
    @Log(title = "用户宠物聊天信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PetMessage petMessage)
    {
        return toAjax(petMessageService.insertPetMessage(petMessage));
    }

    /**
     * 修改用户宠物聊天信息
     */
    @PreAuthorize("@ss.hasPermi('digital:message:edit')")
    @Log(title = "用户宠物聊天信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PetMessage petMessage)
    {
        return toAjax(petMessageService.updatePetMessage(petMessage));
    }

    /**
     * 删除用户宠物聊天信息
     */
    @PreAuthorize("@ss.hasPermi('digital:message:remove')")
    @Log(title = "用户宠物聊天信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(petMessageService.deletePetMessageByIds(ids));
    }
}
